<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>鼠标移动</title>
</head>
<style>
    body {
        width: 100%;
        height: 100vh;
    }

    span {
        transform: rotate(45deg);
    }

    span::after {
        content: "";
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 25px;
        position: absolute;
        top: 0px;
        left: -4px;
        background: red;
    }

    span::before {
        content: "";
        display: block;
        width: 8px;
        height: 8px;
        border-radius: 25px;
        position: absolute;
        top: -4px;
        right: 0;
        background: red;
    }
</style>

<body>
    <script>
        document.addEventListener('click', function (e) {

            var span = document.createElement('span')
            span.style.width = '2px'
            span.style.height = '2px'
            span.style.position = 'absolute'
            span.style.left = e.clientX + 'px'
            span.style.top = e.clientY + 'px'

            span.style.backgroundColor = 'red';
            span.style.transition = 'all 1s'
            document.body.appendChild(span);



            setTimeout(function () {
                var l = Math.floor(Math.random() * 200) - 100;
                var t = Math.floor(Math.random() * 100) + 200
                span.style.left = e.clientX + l + 'px'
                span.style.top = e.clientX - t + 'px'
                span.style.width = '8px'
                span.style.height = '8px'
            }, 4)

            setTimeout(function () {
                document.body.removeChild(span);
            }, 1000)
        })
    </script>
</body>

</html>